#coding=utf-8
# Create your views here.
from comic.models import Comic,ComicForm
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from google.appengine.api import users

def add_comic(request):
    ''' 添加漫画信息 '''
    if request.method == 'GET':
        form = ComicForm()
    if request.method == 'POST':
        form = ComicForm(request.POST)
        if form.is_valid():
            comic = form.save(commit=False)
            comic.owner = users.get_current_user()
            comic.put()
            return HttpResponseRedirect('/')
    return render_to_response('add_comic.html',{'form':form})

def list_comic(request):
    ''' 漫画列表 '''
    comic_list = Comic.all().order('-create_time')
    return render_to_response('list_comic.html',{'comic_list':comic_list})

def del_comic(request):
    ''' 删除漫画 '''
    pass

def update_comic(request):
    ''' 更新漫画信息 '''
    pass

def login(request):
    ''' 用户登录 '''
    pass

def logout(request):
    ''' 用户退出 '''
    pass
